#ifdef __cplusplus
    #include <cstdlib>
#else
    #include <stdlib.h>
#endif

#include <SDL/SDL.h>

int main ( int argc, char** argv )
{ SDL_Event event;
   freopen("CON","w",stdout);
   freopen("CON","r",stdin);
//printf("fdlrihf");
  // initialize SDL video
    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
    {
        printf( "Unable to init SDL: %s\n", SDL_GetError() );
        return 1;
    }

    // make sure SDL cleans up before exit
    atexit(SDL_Quit);

    // create a new window
    SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16,
                                           SDL_HWSURFACE|SDL_DOUBLEBUF);
    SDL_Surface* bmp = SDL_LoadBMP("cb.bmp");
     SDL_Rect dstrect;
    dstrect.x = (screen->w - bmp->w) / 2;
    dstrect.y = (screen->h - bmp->h) / 2;
     SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 255, 255, 0));

        // draw bitmap
        SDL_BlitSurface(bmp, 0, screen, &dstrect);

        // DRAWING ENDS HERE

        // finally, update the screen :)
        SDL_Flip(screen);
while (1)
{ while (SDL_PollEvent(&event))
{
    switch(event.type)
    {
       // case SDL_MOUSEMOTION:
       // int x=event.motion.x;
       // int y=event.motion.y;
       // if (x>dstrect.x&&x<dstrect.x+bmp->w&&y>dstrect.y&&y<dstrect.y+bmp->h)
       // {
           // printf("fattoum");//
       // } else printf ("3loulou");//
   // }//
    case SDL_MOUSEBUTTONDOWN:
        printf ("down");
        break;
    case SDL_MOUSEBUTTONUP:
        printf("up");
        break;

    }

}
    SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 84, 37, 84));

        // draw bitmap
        SDL_BlitSurface(bmp, 0, screen, &dstrect);

        // DRAWING ENDS HERE

        // finally, update the screen :)
        SDL_Flip(screen);

}
    return 0;
}
